package com.liucxu.zimuzu.Base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * 基础Fragment
 * Created by liukanshan on 2016/12/8.
 */

public abstract class BaseFragment extends Fragment{
    private View mContextView;
    private Context mContext;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mContextView=inflater.inflate(getLayoutId(),container,false);
        setupView();
        setupData();
        mContext=getContext();
        return mContextView;
    }

    public abstract int getLayoutId();

    public abstract void setupView();

    public abstract void setupData();

    public <T extends View> T $(int id) {
        return (T) mContextView.findViewById(id);
    }
}
